package com.example.hp.qingyi.compass.fragment.fragment.hotspotadapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.bumptech.glide.Glide;
import com.example.hp.qingyi.R;
import com.example.hp.qingyi.compass.fragment.fragment.base.HotspotBaseData;

import java.util.List;


/**
 * Created by A on 2018/11/7.
 */

public class HotspotTwoAdapter extends RecyclerView.Adapter<HotspotTwoAdapter.MyViewHolder> {
    private List<HotspotBaseData.DataBean> list;
    private Context context;

    public HotspotTwoAdapter(List<HotspotBaseData.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        MyViewHolder holder=new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.hotspot_two_view,parent,false));
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        Glide.with(context).load(list.get(position + 1).getHybrid_cover_std()).into(holder.imageView);//风景图
        Glide.with(context).load(list.get(position + 1).getUsercover()).into(holder.iv_two_tx);//头像
        holder.tv_two_one.setText(list.get(position + 1).getHybrid_title());//头部
        holder.tv_two_zz.setText(list.get(position + 1).getUser_name());//作者
        holder.tv_two_nr.setText(list.get(position + 1).getPost_summary());//内容
    }

    @Override
    public int getItemCount() {
        return 4;
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private ImageView imageView,iv_two_tx;
        private TextView tv_two_one,tv_two_zz,tv_two_nr;
        public MyViewHolder(View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.iv_two);
            iv_two_tx = itemView.findViewById(R.id.iv_two_tx);
            tv_two_one = itemView.findViewById(R.id.tv_two_one);
            tv_two_zz = itemView.findViewById(R.id.tv_two_zz);
            tv_two_nr = itemView.findViewById(R.id.tv_two_nr);
        }
    }
}
